export default function searchTableColumns(that) {
  return [
    {
      title: "单曲",
      key: "name",
      render: (h, params) => {
        return h(
          "a",
          {
            on: {
              click: () => {
                that.musicName = params.row.name;
                that.search();
              }
            }
          },
          params.row.name
        );
      }
    },
    {
      title: "歌手",
      key: "artists",
      render: (h, params) => {
        var artists = params.row.artists;
        if (artists.length > 0) {
          let authorEles = [];
          var index = 0;
          artists.forEach(item => {
            // author += item.name + "/";
            authorEles.push(
              h(
                "a",
                {
                  on: {
                    click: () => {
                      that.musicName = item.name;
                      that.search();
                    }
                  }
                },
                item.name + (index < artists.length - 1 ? "/" : "")
              )
            );
            index++;
          });
          // author = author.substring(0, author.length - 1);
          return h("span", [authorEles]);
        } else return h("span", "未知");
      }
    },
    {
      title: "专辑",
      key: "album",
      render: (h, params) => {
        return h("span", params.row.album.name);
      }
    },
    {
      title: "音质",
      key: "quality",
      render: (h, params) => {
        var quality = params.row.quality;
        var qualities = [];
        if (quality[999]) {
          qualities.push(
            h(
              "Button",
              {
                props: {
                  type: "info",
                  size: "small"
                },
                on: {
                  click: () => {
                    that.play(params.index, 999000);
                  }
                }
              },
              "FLAC"
            )
          );
        }
        if (quality[320]) {
          qualities.push(
            h(
              "Button",
              {
                props: {
                  type: "warning",
                  size: "small"
                },
                on: {
                  click: () => {
                    that.play(params.index, 320000);
                  }
                }
              },
              "MP3"
            )
          );
        }
        return h("ButtonGroup", [qualities]);
      }
    },
    {
      title: "MV",
      key: "mv",
      render: (h, params) => {
        return h(
          "Button",
          {
            props: {
              type: "success",
              size: "small"
            }
          },
          "MV"
        );
      }
    }
    // {
    //   title: "下载",
    //   key: "download",
    //   render: (h, params) => {
    //     return h("span", "未知");
    //   }
    // }
  ];
}
